package org.kfive.nova.hadoop.reducer;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: admin
 * Date: 16-3-28
 * Time: 下午10:32
 * To change this template use File | Settings | File Templates.
 */
public class MaxTemperatureReducer extends Reducer<Text,IntWritable,Text,IntWritable> {

    public void reduce(Text key,Iterable<IntWritable> values,Context context) throws IOException,InterruptedException{

        int maxValue = Integer.MAX_VALUE;

        for (IntWritable value : values){

            maxValue = Math.max(maxValue,value.get());
        }

        context.write(key,new IntWritable(maxValue));
    }
}
